package com.books.service.login_regis.impl;/*
 *@Auther Zhourui
 *@data 2021/9/27  18:09
 *@Email 1605576647@qq.com
 */

import com.books.mapper.common.PeopleMapper;
import com.books.mapper.login_regis.UserRegisMapper;
import com.books.model.entity.common.People;
import com.books.model.entity.login_regis.UserLogin;
import com.books.service.login_regis.IUserRegisService;
import com.books.util.Md5Util;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


@Service
@Transactional
public class UserRegisServiceImpl implements IUserRegisService {
    @Autowired(required = false)
    private UserRegisMapper userRegisMapper;

    @Autowired(required = false)
    private PeopleMapper peopleMapper;

    @Autowired(required = false)
    private People people;

    @Override
    public void registration(UserLogin userLogin) {
        userRegisMapper.setUserLogin(userLogin.getUname(),userLogin.getAccount(), Md5Util.code(userLogin.getPassword()),userLogin.getEmail(), userLogin.getRegisdate(),userLogin.getFace());
    }

    @Override
    public void regisuseradd(UserLogin userLogin) {
        people.setEmail(userLogin.getEmail());
        people.setPhone(userLogin.getAccount());
        people.setRegistrationTime(userLogin.getRegisdate());
        people.setName(userLogin.getUname());
        people.setIfAdmin(false);
        people.setVipId(0);
        people.setStatusId(1);
        people.setVipIntegral(0.00);
        peopleMapper.addPeople(people);

    }
}
